'use strict';

import { basicAction } from '@peace/utils'
import { ApiTable } from '$utils'

export function getFireAlarmList (query) {
   return dispatch => basicAction({
      type: 'get',
      dispatch: dispatch,
      query: query || {},
      actionType: 'GET_FIRE_ALARM',
      url: `${ApiTable.getFireAlarmList}`,
      msg: { error: '获取消防告警列表失败' },
      reducer: { name: 'alarms' }
   });
}

export function addFireAlarm (params) {
   return (dispatch) => basicAction({
      type: 'post',
      data: params,
      dispatch,
      actionType: 'ADD_RIST_REPORT',
      url: ApiTable.getFireAlarmList,
      msg: {
         option: '新增消防告警',
      },
   });
}

export function modifyFireAlarm (id, params) {
   return (dispatch) => basicAction({
      type: 'put',
      data: params,
      dispatch,
      actionType: 'MODIFY_FIRE_ALARM',
      url: ApiTable.modifyFireAlarm.replace('{id}', id),
      msg: {
         option: '',
      },
   });
}


export function getVideoCenterList () {
   return dispatch => basicAction({
      type: 'get',
      dispatch: dispatch,
      actionType: 'GET_VIDEO_CENTER_LIST',
      url: ApiTable.videoCenterList,
      msg: { error: '获取视频中心列表失败' },
      reducer: { name: 'videoCenterList' }
   });
}

export function getDetails () {
   return dispatch => basicAction({
      type: 'get',
      dispatch: dispatch,
      actionType: 'GET_DETAILS',
      url: ApiTable.details,
      msg: { error: '获取南昌市道路数据失败' },
      //  reducer: { name: 'videoCenterList' }
   });
}

export function getSurroundingConditions (query = {}) {
   return dispatch => basicAction({
      type: 'get',
      dispatch: dispatch,
      query: query,
      actionType: 'GET_SURROUNDING_CONDITION',
      url: ApiTable.surroundingConditions,
      msg: { error: '获取周边路况数据失败' },
      //  reducer: { name: 'videoCenterList' }
   });
}


export function getFireDevice () {
   return dispatch => basicAction({
      type: 'get',
      dispatch: dispatch,
      actionType: 'GET_FIRE_DEVICE',
      url: `${ApiTable.getFireDevice}`,
      msg: { error: '获取消防设备失败' },
   });
}

export function getFireTrend () {
   return dispatch => basicAction({
      type: 'get',
      dispatch: dispatch,
      actionType: 'GET_FIRE_TREND',
      url: `${ApiTable.getFireTrend}`,
      msg: { error: '获取火情趋势失败' },
   });
}

